//////////////////////////////////////////////////////////////////////////
//
// This file is a part of XORT project.
//
// PROJECT:         Xort compiler
// FILE:            xprimimpl.h - primitives implementation
// AUTHOR:          Vladimir Gumenuk
// DATE:            11-Dec-2012
//
//
//     Copyright(c) 2014, Vladimir Gumenuk
//     All rights reserved.
//
//     Redistribution and use in source and binary forms, with or without modification, 
//     are permitted provided that the following conditions are met :
//
//     1. Redistributions of source code must retain the above copyright notice, 
//        this list of conditions and the following disclaimer.
//     2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 
//        the following disclaimer in the documentation and / or other materials provided with the distribution.
//     3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse 
//        or promote products derived from this software without specific prior written permission.
//
//     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
//     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
//     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
//     THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
//     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
//     OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
//     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
//     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
//     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#pragma once

// x = -x;
int FASTCALL const_neg( XELEMENT x );

// x = ~x
int FASTCALL const_not( XELEMENT x );

// x += 1;
int FASTCALL const_inc( XELEMENT x );

// x -= 1;
int FASTCALL const_dec( XELEMENT x );

// nz.T        v1 ? -> 1/0
int FASTCALL const_nz( XELEMENT v1, XELEMENT vRes );

// lor.T       v1, v2 || -> 1/0
int FASTCALL const_lor( XELEMENT v1, XELEMENT v2, XELEMENT vRes );

// land.T      v1, v2 && -> 1/0
int FASTCALL const_land( XELEMENT v1, XELEMENT v2, XELEMENT vRes );

// lnot.T      v = !v
int FASTCALL const_lnot( XELEMENT x );

// cmpeq.T     v1, v2 == -> 1/0
int FASTCALL const_cmpeq( XELEMENT v1, XELEMENT v2, XELEMENT vRes );

// cmpneq.T    v1, v2 != -> 1/0
int FASTCALL const_cmpneq( XELEMENT v1, XELEMENT v2, XELEMENT vRes );

// cmpgt.T     v1, v2 >  -> 1/0
int FASTCALL const_cmpgt( XELEMENT v1, XELEMENT v2, XELEMENT vRes );

// cmplt.T     v1, v2 <  -> 1/0
int FASTCALL const_cmplt( XELEMENT v1, XELEMENT v2, XELEMENT vRes );

// cmpge.T     v1, v2 >= -> 1/0
int FASTCALL const_cmpge( XELEMENT v1, XELEMENT v2, XELEMENT vRes );

// cmple.T     v1, v2 <= -> 1/0
int FASTCALL const_cmple( XELEMENT v1, XELEMENT v2, XELEMENT vRes );

// ifz         v1 ? -> ...
int FASTCALL const_ifz( XELEMENT x, int& iResult );

// ifnz        v1 != 0 -> ...
int FASTCALL const_ifnz( XELEMENT x, int& iResult );

// math functions
int FASTCALL arith_or ( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
int FASTCALL arith_xor( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
int FASTCALL arith_and( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
int FASTCALL arith_shl( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
int FASTCALL arith_shr( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
int FASTCALL arith_add( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
int FASTCALL arith_sub( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
int FASTCALL arith_mul( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
int FASTCALL arith_div( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
int FASTCALL arith_mod( XELEMENT v1, XELEMENT v2, XELEMENT vRes );
